package com.usian.admin.controller;

import com.usian.admin.AdChannelControllerApi;
import com.usian.admin.service.AdChannelService;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理",tags = "channel",description = "频道管理API")
public class AdChannelController  implements AdChannelControllerApi {

    @Autowired
    private AdChannelService channelService;

    @ApiOperation(value = "查询频道",notes = "根据名称查询模糊查")
    @PostMapping("/list")
    @Override
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto){
        return channelService.findByNameAndPage(dto);
    }


    @Override
    @PostMapping("/save")
    @ApiOperation(value = "添加频道接口",notes = "接受json串")
    public ResponseResult save(@RequestBody AdChannel channel) {

        return channelService.insert(channel);
    }

    @Override
    @PostMapping("/update")
    @ApiOperation(value = "修改频道信息接口",notes = "接受json串")
    public ResponseResult update(@RequestBody AdChannel adChannel) {

        return channelService.update(adChannel);
    }

    @Override
    @GetMapping("/del/{id}")
    @ApiOperation(value = "删除频道接口",notes = "Integer类型")
    public ResponseResult deleteById(@PathVariable("id")Integer id) {
        return channelService.deleteById(id);
    }

    @Override
    public ResponseResult findAll() {
        return channelService.findAll();
    }


}